package com.wangnan.service;

import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;

@Service
public class RestService {

    @Autowired
    RestTemplate restTemplate;

    @HystrixCommand(fallbackMethod = "isAliveBack")
    public String isAlive(){
        String url = "http://user-provider/isAlive";
        String result = restTemplate.getForObject(url,String.class);
        return result;
    }

    public String isAliveBack(){
        return "呵呵，服务降级了";
    }
}
